package com.bdweb.controller;

import com.bdweb.model.WEAK;
import com.bdweb.pojo.Result;

import com.bdweb.service.WeakService;

import com.bdweb.service.impl.MedailServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
@RestController

public class weakController  {
    @Autowired
    private WeakService weakService ;

    // 获取多媒体数据
    @CrossOrigin(origins = "*")   //设置跨域
    @GetMapping("/medalist")
    public Result getWeakList(){
        List<WEAK> allWeak = weakService.findAllWeak();
       // System.out.println(allWeak);

        return new Result(200,"success",allWeak);
    }



    //发起开关命令
    @Autowired
    private MedailServiceImpl medailService;
    @CrossOrigin(origins = "*")   //设置跨域
    @GetMapping("/switchList")
    public Result getMediasSwitch(int id) throws IOException, InterruptedException {
        // 开启或者关闭


        if(id<4){
            Result openSwitch = medailService.listMedailOpen(id);
            return openSwitch;
        }
        else {
            Result closeSwitch = medailService.listMedailClose(id);
            return closeSwitch;
        }



    }

}
